package cn.mybatis.plugin.service.impl;

import cn.mybatis.plugin.domain.PageInfo;
import cn.mybatis.plugin.mapper.UserMapper;
import cn.mybatis.plugin.pagehelper.Page;
import cn.mybatis.plugin.pagehelper.PageHelper;
import cn.mybatis.plugin.service.MybatisService;
import cn.mybatis.plugin.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @author: 张澎_9970
 * @date: 2022.1.17 下午 11:07
 */
@Service
public class MybatisServiceImpl implements MybatisService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public PageInfo<User> gen(int page, int size) {
        Page<User> p = PageHelper.startPage(page, size);
        userMapper.gen();

        PageInfo<User> userPageInfo = new PageInfo<>();
        userPageInfo.setPageNum(page);
        userPageInfo.setPageSize(size);
        userPageInfo.setTotal(p.getTotal());
        userPageInfo.setList(p);
        return userPageInfo;
    }
}
